#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

import MySQLdb

DATABASE_NAME = 'plosp'
HOST = '10.188.188.22'
PORT = '3306'
USER_NAME = 'plosp'
PASSWORD = 'plosp'
CHAR_SET = 'utf8'

# ht_p={}
# ht_e={}
ht = {}

conn = MySQLdb.connect(host=HOST, user=USER_NAME, passwd=PASSWORD, db=DATABASE_NAME, charset=CHAR_SET)
cursor = conn.cursor()
# sql = "SELECT issn_print,issn_electronic FROM tb_dds_journal"
# results=cursor.execute(sql)
#
# for result in cursor.fetchall():
#     if result[0] != None:
#         if not ht_p.has_key(result[0]):
#             ht_p[result[0]]=1
#         else:
#             ht_p[result[0]]+=1
#     if result[1] != None:
#         if not ht_e.has_key(result[1]):
#             ht_e[result[1]]=1
#         else:
#             ht_e[result[1]]+=1

# sql = "SELECT Unique_Nlm_ID FROM tb_dds_journal"
# results = cursor.execute(sql)
#
# for result in cursor.fetchall():
#     if result[0] != None:
#         if not ht.has_key(result[0]):
#             ht[result[0]] = 1
#         else:
#             ht[result[0]] += 1

sql = "SELECT title FROM tb_dds_journal"
results = cursor.execute(sql)

for result in cursor.fetchall():
    if result[0] != None:
        if not ht.has_key(result[0]):
            ht[result[0]] = 1
        else:
            ht[result[0]] += 1

cursor.close()
conn.close()

# for key in ht_p.keys():
#     if ht_p[key]>=2:
#         print key
# print "======================================="
# for key in ht_e.keys():
#     if ht_e[key]>=2:
#         print key

for key in ht.keys():
    if ht[key] >= 2:
        print key
